/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eu.games.esmi.ieat.indicatorrelations;

import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.Table;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import eu.games.esmi.ieat.indicatorrelations.data.AssociationRule;

/**
 *
 * @author user
 */
public class AssociationAnalysisTab extends Panel {
    
    private Table table = new Table();
    
    public AssociationAnalysisTab() {
        super();
        init();
    }
    
    public void init() {
        
        //VerticalLayout vl = new VerticalLayout();
        //vl.setSpacing(true);
        
        //vl.addComponent(new Label("Indicators"));
        this.addComponent(new Label("Defined associations"));
        

        final BeanItemContainer<AssociationRule> tableContainer = new BeanItemContainer<AssociationRule>(AssociationRule.class);
        table.setContainerDataSource(tableContainer);
        table.setWidth(640, Sizeable.UNITS_PIXELS);
        table.setVisibleColumns(new Object[] { "association", "confidence", "support" });
//        table.addItem(new AssociationRule("CPU usage s1 > CPU usage s2", "", ""));
//        table.addItem(new AssociationRule("red & green", "0.9", "0.4"));
        
        //TODO PROVA!!!
        //Tabs.INSTANCE.correlationAnalysisTab = this;
        
        this.addComponent(table);
        //vl.addComponent(table);

        //vl.addComponent(new IndicatorChart());
        
        //this.addComponent(vl);
        
        //TextArea area = new TextArea("Data Mining result", Miner.demo());
        //this.addComponent(area);
    }
    
    public void addAssociationToTable(String association, String confidence, String support) {
        table.addItem(new AssociationRule(association, confidence, support));
    }

    void clearAssociationTable() {
        table.removeAllItems();
    }
}
